{% extends 'layout_base.html' %}

{% block stylesheets %}
{{ block.super }}
  <link href="/media/css/stats.css" type="text/css" rel="stylesheet" />
{% endblock %}

{% block scripts %}
  {{ block.super }}
  <script type="text/javascript" src="/media/js/stats.js" ></script>
{% endblock %}

{% block page_title %}{{ target.title }}{% endblock %}
{% block head_title %}{{ target.title }}{% endblock %}

{% block content %}
<div id="columns">

<div id="info-column">
  {% if target.subtitle %}
    <p class="subtitle">{{ target.subtitle|escape }}</p>
  {% endif %}
  {% if target.url %}
    <p class="url"><a href="{{ target.url|escape }}">{{ target.url|escape }}</a></p>
  {% endif %}
  {% if target.photo %}
    <p class="photo">{{ target.photo.get_large_thumbnail.to_html }}</p>
  {% endif %}
  {% if target.description %}
    <p class="description">{{ target.description|escape }}</p>
  {% endif %}

  {% if target.is_editable %}
    <p class="edit"><a href="{{ target.get_asset_edit_url }}">Edit this page...</a></p>
  {% endif %}
</div>

<div id="message-column">
  <div id="timeline-bar"> </div>

  <div id="messages">
    <div><div><div><div><div><div>
    {% for message in recent_messages %}

    {% ifchanged message.timestamp.date %}
      </div></div>
      {% ifchanged message.get_year_and_month %}</div></div>{% endifchanged %}
      {% ifchanged message.timestamp.year %}</div></div>{% endifchanged %}

      <div class="timestamp-headings">
	{% ifchanged message.timestamp.year %}
	  <span class="expander-open" id="expander-{{ message.timestamp|date:"Y" }}"
	        onclick="expandYear({{ message.timestamp|date:"'Y','m','d'" }})">
	    <img src="/media/img/tlexpand-open.png" width="10" height="10" />
	    {{ message.timestamp|date:"Y" }}</span>
	{% endifchanged %}

	{% ifchanged message.get_year_and_month %}
	  <span class="expander-open" id="expander-{{ message.timestamp|date:"Y-m" }}"
	        onclick="expandMonth({{ message.timestamp|date:"'Y','m','d'" }})">
	    <img src="/media/img/tlexpand-open.png" width="10" height="10" />
	    {{ message.timestamp|date:"F" }}</span>
	{% endifchanged %}

	<span class="expander-open" id="expander-{{ message.timestamp|date:"Y-m-d" }}"
	      onclick="expandDay({{ message.timestamp|date:"'Y','m','d'" }})">
	  <img src="/media/img/tlexpand-open.png" width="10" height="10" />
	  {{ message.timestamp|date:"l \t\h\e jS" }}</span>
      </div>

      {% ifchanged message.timestamp.year %}<div id="msg-{{ message.timestamp|date:"Y" }}"><div>{% endifchanged %}
      {% ifchanged message.get_year_and_month %}<div id="msg-{{ message.timestamp|date:"Y-m" }}"><div>{% endifchanged %}
      <div id="msg-{{ message.timestamp|date:"Y-m-d" }}"><div>
    {% endifchanged %}

    <div class="message">
      <div class="timestamp"><span>{{ message.timestamp|time:"H:i" }}</span></div>

      {% if message.is_commit %}

        <a class="message" href=".message/{{ message.hex_id }}">
          {% if message.version %}<span class="version">{{ message.version|escape }}</span>{% endif %}
          {% if message.revision %}r<span class="revision">{{ message.revision|escape }}</span>{% endif %}
  	  <span class="separator">::</span>
	  <span class="module">{{ message.module }}</span>/{{ message.format_files }}
        </a>

        {% if message.url %}<p class="url"><a href="{{ message.url|escape }}">{{ message.url|escape }}</a></p>{% endif %}

        <div class="log">{{ message.format_log }}</div>

      {% else %}
        {{ message.to_html }}
        <p><a href=".message/{{ message.hex_id }}" >Details...</a></p>
      {% endif %}
    </div>

    {% endfor %}
    </div></div></div></div></div></div>
  </div>

</div>

</div>
{% endblock %}
